package com.qf.controller;

import com.qf.entity.DeptVo;
import com.qf.entity.Emp;
import com.qf.entity.EmpVo;
import com.qf.service.EmpService;
import com.qf.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * --- 天道酬勤 ---
 *
 * @author GUOFUCHENG
 * @date 2025/8/11
 * @desc
 */
@RestController
public class Demo2Controller {
    @Autowired
    private EmpService empService;

    // 查询员工对应的部门信息 一对一
    @GetMapping("/emp/dept/{empno}")
    public R findDetpWithEmpByEpmno(@PathVariable int empno){
        System.out.println("empno = " + empno);
        EmpVo empVo= empService.sreach(empno);
        return R.success(empVo);
    }

    //一对多 查询部门下所有的员工信息

    @GetMapping("/dept/emp/{deptno}")
    public R find(@PathVariable int deptno){
        System.out.println("deptno = " + deptno);
        DeptVo deptVo = empService.findInfo(deptno);
        return R.success(deptVo);
    }

}
